package com.suray.system.run.type;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.suray.basic.wcs.utils.IBaseEnum;

import java.io.Serializable;

public enum TaskType implements IBaseEnum<Serializable> {
    /**
     * 入库, 小车从当前点出发, 空载前往入库口, 载重行驶并停在入库货位(入库口作为起点坐标, 入库货位作为终点坐标)
     */
    IN(0, "入库"),
    /**
     * 出库, 小车从当前点出发, 空载行驶至出库货位取货, 载重行驶并停在出库口(出库货位作为起点坐标, 出库口作为终点坐标)
     */
    OUT(1, "出库"),
    /**
     * 移库, 小车从当前点出发, 空载前往移库取货点取货(作为起点), 载重行驶并停在移库放货点(作为终点)
     */
    TRANSFER(2, "移库"),
    /**
     * 充电, 小车从当前点出发, 空载行驶至充电桩充电(不需要起点终点)
     */
    CHARGE(3, "充电"),
    /**
     * 载重行驶, 小车从当前点出发, 穿货位到达终点(只需要终点)
     */
    MOVE_LOADED(4, "载货行驶"),
    /**
     * 空载行驶, 小车从当前点出发, 不穿货位到达终点(只需要终点)
     */
    MOVE_UNLOADED(5, "空载行驶"),
    /**
     * 工位行驶, 输送线行驶
     */
    MOVE_STATION(6,"工位行驶"),
    /**
     * 工位行驶, 输送线行驶
     */
    CHECK_GCODE(10,"检测地码"),
    ;

    @EnumValue
    private int taskType;
    @JsonValue
    private String description;

    TaskType(int taskType, String description) {
        this.taskType = taskType;
        this.description = description;
    }

    @Override
    public String toString() {
        return description;
    }

    public static TaskType parseTaskType(int taskType) {
        TaskType[] taskTypes = TaskType.values();
        for (TaskType type : taskTypes) {
            if (type.taskType == taskType) {
                return type;
            }
        }
        throw new IllegalArgumentException("任务类型参数错误:" + taskType);
    }

    public static TaskType getByTaskType(int taskType) {
        TaskType[] taskTypes = TaskType.values();
        for (TaskType type : taskTypes) {
            if (type.taskType == taskType) {
                return type;
            }
        }
        return null;
    }

    public static TaskType parseTaskType(String description) {
        TaskType[] taskTypes = TaskType.values();
        for (TaskType type : taskTypes) {
            if (type.description.equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("任务类型描述错误:" + description);
    }

    public int getTypeNum() {

        return taskType;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public Integer getValue() {
        return taskType;
    }

    @Override
    public Integer getVal() {
        // TODO Auto-generated method stub
        return null;
    }


}
